let ErrorUtils = require('../utils/error/ErrorUtils');
let AdminLoginService = require('../service/adminLogin');
let EmailService = require('../service/email');
let ResponseUtils = require('../utils/ResponseUtils');
const {infoLogger, errorLogger} = require('../config').logger;

class AdminLoginController {

    static async login(ctx) {
        let data = ctx.request.body;
        infoLogger.info("后端登录接口开始了,请求参数", data);
        let result = await AdminLoginService.login(data);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async register(ctx){
        let data = ctx.request.body;
        infoLogger.info("后端登录接口开始,请求参数", data);
        let result = await AdminLoginService.register(data);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async sendEmail(ctx){
        let data = ctx.request.body;
        infoLogger.info("后端发送邮箱验证码接口开始,请求参数", data);
        let result = await EmailService.sendEmailCode(data);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
    static async findVerifyInfo(ctx) {
        let result = await AdminLoginService.findVerifyInfo(ctx);
        ctx.body = ResponseUtils.builder(result).success().build();
    }
}

module.exports = AdminLoginController;
